package com.zg.CliemtManage;

import com.zg.domain.DataForClient;
import io.netty.handler.codec.mqtt.MqttConnAckMessage;
import io.netty.handler.codec.mqtt.MqttConnectReturnCode;
import io.netty.handler.codec.mqtt.MqttMessage;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 检查是否运行该用户上线
 * 默认使用用户名密码模式，可根据自己的业务更改
 */
@Component
public class ClientCheck {

    private ConcurrentHashMap<String,String> user_password = DataForClient.getUser_password();

    @PostConstruct
    public void init(){
        user_password.put("admin","admin");
    }

    public boolean checkClient(String username,String password){
        if (user_password.containsKey(username)){
            String s = user_password.get(username);
            if (s.equals(password)){
                return true;
            }
        }
        return false;
    }

}
